Decimation of fixed length queues

ABSTRACT

Decimation of data from a fixed length queue retaining a representative sample of the old data. Exponential decimation removes every nth sample. Dithered exponential decimation offsets the exponential decimation approach by a probabilistic amount. Recursive decimation selects a portion of the queue and removes elements.

BACKGROUND OF THE INVENTION

[0001] 1. Field of the Invention

[0002] The present invention deals with fixed-length queues in computerhardware and software. More specifically, the present invention dealswith techniques for managing fixed-length queues when they become full.

[0003] 2. Art Background

[0004] Many systems use fixed-length queues to buffer data between adata producer and a data consumer. If the consumer is not able toconsume data as fast as the producer places it in the queue, or isunable for some reason to take data from the queue or empty the queue,the queue can become full. The queue management system, hardware orsoftware, must have policies in place for dealing with queue overflowsituations.

[0005] Traditional approaches to queue overflow include techniques suchas overwriting the last item, dropping the oldest item, or discardingthe newest item. The choice is usually made based on the needs of theapplication and the presumed importance of new data versus old data.

SUMMARY OF THE INVENTION

[0006] Techniques for decimation, the removal of old data, from a fixedlength queue retain a representative sample of the data Exponentialdecimation removes every nth sample. Dithered exponential decimationapplies an offset to the exponential decimation approach. Recursiverandom decimation selects a portion of the queue and removes elements,and recurses on the remaining portion of the queue.

BRIEF DESCRIPTION OF THE DRAWINGS

[0007] The present invention is described with respect to particularexemplary embodiments thereof and reference is made to the drawings inwhich:

[0008]FIG. 1 shows a fixed length queue,

[0009]FIG. 2 shows exponential decimation in a fixed length queue, and

[0010]FIG. 3 shows recursive decimation in a fixed length queue.

DETAILED DESCRIPTION

[0011]FIG. 1 shows a fixed length queue 100 of 10 elements, where eachitem in the queue is represented by its sample number. Element 1 is theoldest element in the queue, element 2 the next oldest, and so onthrough element 10 which is the newest. Queue 100 is full. When a newitem arrives, either the new item must be discarded, or room must bemade for it in the queue. Prior art solutions to adding a new item to afull queue include discarding the new item, and overwriting the mostrecently added item. The approach used depends on the needs of theapplication, and the presumed importance of old data versus new data.

[0012] Decimation as taught by the present invention trades reducedaccuracy for increased apparent size of the queue. For example, if a 60element queue contains samples taken every second, the queue when fullholds samples spanning a minute, with one sample for every second inthat minute. After many rounds of applying the decimation techniquesaccording to the present invention, the same 60 element queue holds datacovering a time span equivalent to that of a queue many times that size.However, the queue no longer contains a sample for each second of thattime span.

[0013] The embodiments of the present invention may be implemented in awide range of software, ranging from microcode or very low-levelimplementations to high-level language implementations. Embodiments ofthe present invention may also be implemented directly in hardware.

[0014] It should be understood that truly random numbers are verydifficult to generate, and that the term random in this context isunderstood to be a shorthand for pseudorandom numbers. The generation ofpseudorandom numbers is well understood in the art, described at lengthfor example in Chapter 3 of The Art of Computer Programming by Donald E.Knuth.

[0015] Exponential decimation removes samples from the queue in such away that old data is removed at the expense of new data, while stillmaintaining a representative sampling of the old data. An example ofexponential decimation is shown in FIG. 2. Fixed length queue 200 isfull. Exponential decimation by n=2 removes every second sample beforeadding a new item, removing items 2, 4, 6, 8, and 10 from queue 200 toproduce queue 210 New samples are added until the queue once again isfull, shown in 220. Decimation is repeated and a new sample added,removing every second item, namely items 3, 7, 11, 13, and 15, producingqueue 230. As decimation continues, the distribution of the data becomesexponential in nature.

[0016] Exponential decimation can also be applied with divisors otherthan n=2 and can begin with any item in the queue, effectively adjustingthe exponential rate of decay of old data in the queue. Whileexponential decimation may be applied to a queue removing multipleelements at one time, as shown in FIG. 2, it may also be practicedremoving one element at a time. This requires that the decimationprocess retain state between invocations. As an example, consider thecase of a 10 element queue and divisor n=2. The first time thedecimation process is called, the item in position 2 of the queue isremoved. The next time the decimation process is called, the item inposition 4 of the queue is removed, then the item in position 6, thenthe item in position 10, and then the item in position 2 once again.Applying the decimation process gradually in this manner essentiallyallows the queue to remain full at all times once it has initially beenfilled, eliminating old items only when necessary

[0017] Exponential decimation may also be dithered, probabilisticallyadding (or subtracting) a dither offset m to the sample position to beremoved. At each position a probability of offsetting is calculated. Asan example with the case of exponential decimation with a divisor of n=2and an offset of m=1, samples at positions 2, 5, 7, and 8 in the queueare removed, rather than positions 2, 4, 6, and 8. Dithered exponentialdecimation gives the same emphasis to old data, but is less susceptibleto sample bias. In the general case of dithered exponential decimationwhere the divisor is n and the dither value is ±m, the distributionfunction should ideally be uniform with a zero mean, but anydistribution will do.

[0018] Another method of removing data from a full queue according tothe present invention is recursive decimation. This is shown in FIG. 3.300 shows a full queue of 16 items. Recursive decimation begins bydividing the queue in half. If the queue size is not an integer power of2, some method can be used to make it a power of two in all rounds butthe first. For example, assume the queue size is s and let m=└log₂(s)┘.Then the older “half” of the queue contains the oldest 2^(m) elementsand the newer “half” contains the rest. Select the newer half of thequeue, shown as 310 with items 9-16 in bold, and delete a point atrandom, shown in 320 with item 10 replaced by an X.

[0019] The process is repeated recursively with the remaining half ofthe queue, shown in 330. The newer half is selected, items 5-8 in 340.An element is deleted at random, item 7 replaced by an X in 350.Recursive decimation continues in the same fashion with 360-380.

[0020]390-410 represent the end of the recursive process. When the queuesize being examined is equal to two, one of the elements is deleted atrandom and the recursive process terminated.

[0021] The overall result of this example of random recursive decimationis shown as 420. As with exponential decimation, recursive decimationmay be applied over the entire queue, recursively decimatingsuccessively smaller portions of the queue, or it may be applied onerecursive round at a time, maintaining state between rounds. Again,applying the decimation process gradually in this manner essentiallyallows the queue to remain full at all times once it has initially beenfilled, eliminating old items only when necessary

[0022] As stated, certain aspects of the computation are simplified ifthe queue length in recursive decimation is an integer power of 2. Whilea random number may be generated each time an element is to be deleted,if the queue size is indeed an integer power of 2, a single randomlygenerated number may suffice, since in a sufficiently random number allbits in a binary representation will be random.

[0023] As an example, consider a queue containing 64 elements. In thefirst recursion, a random position spanning items 33 to 64 must beselected, requiring a random number in the range of 0-31. A randomnumber is generated and five consecutive bits (either right most orleftmost) are selected to span the range 0-31. In the next round ofrecursion, the range needed is 0-15, so the next 4 bits of the randomnumber are used. The next round uses 3 bits for a range of 0-7, thefollowing round uses 2 bits for 0-3, and the final round uses 1 bit. Intotal then, 5+4+3+2+1=15 bits are needed in total. In general, thenumber of bits k needed for a queue of size n is:$k = \frac{{\log (n)}^{2} - {\log (n)}}{2}$

[0024] This approach generates a single random number and does not reusebits. While the possibility of introducing sample bias is increased, analternate approach is to generate a single random number with at leastthe number of bits required for the first round of recursion, and reusethat random number in succeeding rounds, selecting fewer bits for eachround.

[0025] If the size of the queue is not an integer power of 2, randomnumbers may be generated individually for each round of recursivedecimation, or a single random number may be generated and reused insuccessive stages, for example by taking the random number modulo thequeue size at issue in each round.

[0026] The foregoing detailed description of the present invention isprovided for the purpose of illustration and is not intended to beexhaustive or to limit the invention to the precise embodimentsdisclosed. Accordingly the scope of the present invention is defined bythe appended claims.

We claim:
 1. The method of removing elements from a fixed-length queue,the method comprising decimation of elements from the queue.
 2. Themethod of claim 1 where the decimation method comprises exponentialdecimation.
 3. The method of claim 2 where exponential decimation isapplied to remove multiple elements from the queue.
 4. The method ofclaim 2 where exponential decimation is applied to remove a singleelement from the queue.
 5. The method of claim 1 where the decimationmethod comprises exponential decimation with dithering.
 6. The method ofclaim 1 where the decimation method comprises recursive decimation,recursively selecting a portion of the queue and removing a randomlychosen element.
 7. The method of claim 6 where separate random numbersare used for each removal of an element from the selected portion of thequeue.
 8. The method of claim 6 where a single random number isgenerated for the recursive decimation process, each step of the processusing only as many bits of the random number as needed.
 9. The method ofclaim 6 where recursive decimation is applied to remove multipleelements from the queue.
 10. The method of claim 6 where recursivedecimation is applied to remove a single element from the queue.
 11. Anarticle of manufacture for performing decimation of a fixed lengthqueue, the article of manufacture comprising: at least one computerreadable medium; processor instructions contained on the computerreadable medium, the instructions configured to be readable by at leastone processor and to cause the processor to remove elements from a fixedlength queue by decimation.
 12. The article of claim 11, where thedecimation method comprises exponential decimation.
 13. The article ofclaim 11 where the decimation method comprises exponential decimationwith dithering.
 14. The article of claim 11 where the decimation methodcomprises recursive decimation, recursively selecting a portion of thequeue and removing a randomly chosen element.
 15. The article of claim11 where the decimation method removes multiple elements from the queue.16. The article of claim 11 where the decimation method removes a singleelement from the queue.
 17. The article of claim 14 where separaterandom numbers are used for each removal of an element from the selectedportion of the queue.
 18. The article of claim 14 where a single randomnumber is generated for the recursive decimation process, each step ofthe process using only as many bits of the random number as needed.